package moa.classifiers;

import moa.streams.DynamicInstanceStream.StructuralChangeInstance;
import moa.streams.DynamicInstanceStream.StructuralChangeType;
import weka.core.Attribute;
import weka.core.Instance;

public abstract class AbstractAdaptableClassifier extends AbstractClassifier implements AdaptableClassifier{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public void trainOnInstance(Instance inst) {
		if (inst instanceof StructuralChangeInstance) {
			try {
				StructuralChangeInstance change = (StructuralChangeInstance) inst;
				if (change.type == StructuralChangeType.ADD_ATTRIBUTE) {
					newAttribute(change.attribute);
				} else if (change.type == StructuralChangeType.ADD_ATTRIBUTE_VALUE) {
					newAttributeValue(change.attribute, change.value);
				} else if (change.type == StructuralChangeType.DELETE_ATTRIBUTE) {
					deletedAttribute(change.attribute);
				} else if (change.type == StructuralChangeType.DELETE_ATTRIBUTE_VALUE) {
					deletedAttributeValue(change.attribute, change.value);
				} else if (change.type == StructuralChangeType.ADD_LABEL) {
					addLabel(change.attribute);
				} else if (change.type == StructuralChangeType.DEL_LABEL) {
					delLabel(change.attribute);
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			super.trainOnInstance(inst);
		}
	}

	@Override
	public void newAttribute(Attribute att) throws Exception {
		throw new Exception("not implemented!");
	}

	@Override
	public void newAttributeValue(Attribute att, String value) throws Exception {
		throw new Exception("not implemented!");
	}

	@Override
	public void deletedAttribute(Attribute att) throws Exception {
		throw new Exception("not implemented!");
	}

	@Override
	public void deletedAttributeValue(Attribute att, String value) throws Exception {
		throw new Exception("not implemented!");
	}

	@Override
	public void delLabel(Attribute attribute) throws Exception {
		throw new Exception("not implemented!");
	}

	@Override
	public void addLabel(Attribute attribute) throws Exception {
		throw new Exception("not implemented!");
	}
	
	
	
}
